/*
实现自定义数据的发布者节点
1.节点初始化。
2.编辑消息对象。pub = nh.advertise<M>(topic_name,queue_size);
3.发布消息（while true）。pub.publish(msg)
4.设置发送频率
*/

#include "ros/ros.h"
#include "plumbing_pub_sub/Person.h"

int main(int argc, char *argv[])
{
    setlocale(LC_ALL, "");
    ros::init(argc, argv, "banZhuRen");
    ros::NodeHandle nh;
    ros::Publisher pub = nh.advertise<plumbing_pub_sub::Person>("age_info", 10);
    plumbing_pub_sub::Person msg;
    msg.name = "张三";
    msg.age = 0;
    msg.height = 1.73;
    //设置发送频率
    ros::Rate rate(2);
    while (ros::ok())
    {
        msg.age += 1;
        pub.publish(msg);
        rate.sleep();
        ROS_INFO("自定义发布年龄消息：%d", msg.age);
        ros::spinOnce();
    }

    return 0;
}
